import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { NgModule, ErrorHandler } from '@angular/core';
import { HttpModule } from '@angular/http';
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
import { NgZorroAntdModule } from 'ng-zorro-antd';

import { AppComponent } from './app.component';
import { AppRouterModule } from './app.router.module';
import { SharedModule } from './shared.module';

//http
import { HttpService } from '../HTTP/http.service';
import { RequestInterceptor } from '../HTTP/http.interceptor';

//apirequest
import { AuthorizeApirequest } from '../ApiRequest/Authorize.Apirequest';
import { AccountApirequest } from '../ApiRequest/Account.Apirequest';

// errorhandle
// import { SELF_ERRORHANDLER } from '../ErrorHandler/errorhandler.service';

// i18n
import { registerLocaleData } from '@angular/common';
import localeZh from '@angular/common/locales/zh';

// 注册
registerLocaleData(localeZh, 'zh-cn');

const APIRequest = [
  AuthorizeApirequest,
  AccountApirequest,
];

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    AppRouterModule,
    SharedModule,
    NgZorroAntdModule.forRoot(),
    BrowserAnimationsModule,
    HttpModule,
    HttpClientModule,
  ],
  providers: [
    ...APIRequest,
    HttpService, 
    { //拦截器
      provide: HTTP_INTERCEPTORS,
      useClass: RequestInterceptor,
      multi: true
    },
    // {
    //   provide: ErrorHandler,
    //   useClass: SELF_ERRORHANDLER
    // }
  ],
  bootstrap: [AppComponent]
})
export class AppModule { }
